package com.Interface.TestIO;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;

public class test9 {

    public static void main(String[] args) {
        String path1 = "D:\\JAVA\\schoolSystem\\src\\com\\Interface\\TestIO\\file\\1.txt";
        try (InputStream inputStream = new FileInputStream(path1);
             Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {

            char[] chars = new char[1024]; // 使用一个合适的缓冲区大小
            int bytesRead;

            while ((bytesRead = reader.read(chars)) != -1) {
                // 处理读取到的字符
                for (int i = 0; i < bytesRead; i++) {
                    if (chars[i] != ' ') {
                        System.out.print(chars[i]);

                    }
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}